import logging

# 创建自定义格式器
formatter = logging.Formatter(
    fmt='%(asctime)s - %(levelname)s - %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S'  # 自定义时间格式
)
global_logger = None

def __init_global_logger():
    # 获取日志处理器并设置格式器
    handler = logging.StreamHandler()
    handler.setFormatter(formatter)

    # 配置日志
    logger = logging.getLogger()
    logger.addHandler(handler)
    logger.setLevel(logging.INFO)
    return logger

def get_logger():
    global global_logger
    if global_logger is None:
        global_logger = __init_global_logger()
    return global_logger
